<template>
  <div class="hello-world">
    <h2 class="text-2xl font-bold mb-4">{{ title }}</h2>
    <p class="mb-4">{{ message }}</p>
    
    <div class="counter-demo">
      <div class="counter-display">
        <span class="count-value">{{ count }}</span>
        <span class="count-label">当前计数</span>
      </div>
      
      <div class="counter-actions">
        <button @click="decrement" class="btn btn-secondary">-</button>
        <button @click="reset" class="btn btn-secondary">重置</button>
        <button @click="increment" class="btn btn-primary">+</button>
      </div>
      
      <div class="counter-info">
        <p>双倍值: {{ doubleCount }}</p>
        <p>是否为偶数: {{ isEven ? '是' : '否' }}</p>
      </div>
    </div>
  </div>
</template>

<script setup>
import { useCounterStore } from '../stores/counter'

defineProps({
  title: {
    type: String,
    default: '欢迎使用组件'
  },
  message: {
    type: String,
    default: '这是一个可复用的Vue组件示例'
  }
})

const counterStore = useCounterStore()
const { count, doubleCount, isEven, increment, decrement, reset } = counterStore
</script>

<style scoped>
.hello-world {
  text-align: center;
  padding: 2rem;
}

.counter-demo {
  max-width: 300px;
  margin: 0 auto;
  padding: 1.5rem;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.counter-display {
  margin-bottom: 1.5rem;
}

.count-value {
  display: block;
  font-size: 3rem;
  font-weight: bold;
  color: #667eea;
  margin-bottom: 0.5rem;
}

.count-label {
  color: #64748b;
  font-size: 0.875rem;
}

.counter-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.counter-info {
  font-size: 0.875rem;
  color: #64748b;
}

.counter-info p {
  margin: 0.25rem 0;
}
</style> 